﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using DataService;
using DataAccess;



namespace WcfService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    [DataContract]
    public class WcfArticlesService : IArticles
    {
        private readonly ArticlesService _serviceArticles;
        
        public WcfArticlesService()
        {
            _serviceArticles =
                new ArticlesService(ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
        }

        
        #region Implementation of IArticles

        public Article AddArticleWithAutor(Article article, string name)
        {
            return _serviceArticles.AddArticleWithAutor(article, name);
        }

        public Article GetArticle(int articleId)
        {
            return _serviceArticles.GetArticle(articleId);
        }

        public void UpdateArticle(Article article)
        {
            _serviceArticles.UpdateArticle(article);
        }

        public void RemoveArticle(int id)
        {
            _serviceArticles.RemoveArticle(id);
        }

        public List<Article> GetAuthorArticles(string authorName)
        {
            return _serviceArticles.GetAuthorArticles(authorName);
        }

        public bool AddAuthorToArticle(int articleId, string authorName)
        {
            return _serviceArticles.AddAuthorToArticle(articleId, authorName);
        }

        public bool RemoveAuthorFromArticle(int articleId, string authorName)
        {
            return _serviceArticles.RemoveAuthorFromArticle(articleId, authorName);
        }

        public List<Article> GetAllArticles()
        {
            return _serviceArticles.GetAllArticles();
        }

        #endregion
    }
}
